<!--
 * @Author: hucc
 * @Date: 2021-10-12 16:58:37
 * @LastEditors: hucc
 * @LastEditTime: 2021-10-12 20:08:57
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="app">
        <my-com :level="1">
            hello render
        </my-com>
        <my-com :level="2">
            hello render
        </my-com>
        <my-com :level="3">
            hello render
        </my-com>
    </div>
    <script>
        let component1 = {
            data() {
                return {}
            },
            props: {
                level: {
                    type: [Number, String],
                    required: true
                }
            },
            render(createElement) {
                //createElement() 三个参数 第一个参数是生成的html标签 
                //第二个参数是生成标签上的属性 第三个参数是生成标签的子节点
                //第一个参数和第三个参数必填 第二个参数可省略
                return createElement(
                    'h' + this.level, //生成的html标签
                    {
                        class: 'box',
                        //title: 'hello'
                    }, //生成标签上的属性
                    //$+属性 实例属性 +方法 实例方法
                    this.$slots.default //生成标签的子节点
                )
            }
        }
        let vm = new Vue({
            el: '#app',
            data: {

            },
            methods: {},
            created() {},
            components: {
                'myCom': component1
            }
        })
    </script>
</body>

</html>